#!/usr/bin/python

import os
import sys
import logging
import JoDef

from logging.handlers import RotatingFileHandler

def setup(lname):
	try:
		os.mkdir(JoDef.JOLOGDIR)
	except:
		pass
	logfile = JoDef.JOLOGDIR+"jo.log"
	jolog = logging.getLogger(lname)
	jolog.setLevel(logging.INFO)

	handler = RotatingFileHandler(logfile,'a',100*1024,10)
	format = '%(asctime)s %(levelname)s '+os.getenv("JOUSER","")+' %(message)s'
	fmt = logging.Formatter(format )
	handler.setFormatter( fmt )
	jolog.addHandler( handler ) 
	return jolog

